home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / acc_obj0 / t_egb_0a.dpr < prev    next >
Encoding:
Text File  |  1995-12-22  |  2.1 KB  |  55 lines

  1. PROGRAM T_EGB_0a;
  2.  
  3. { PGM FOR DEMONSTRATING THE tBufTextFileReader ACCESS OBJECT }
  4.  
  5. { This programs reads an AutoCAD DXF text file with an access object
  6.   of tBufTextFileReader class and then with one of the
  7.   tBufTextStringFileReader class.
  8.  
  9. { Pgm. 07/19/95 by John F Herbster for CIS Delphi Object Pascal Lib. }
  10.  
  11. {-----} USES {---------------------------------------------------------}
  12.   U_EGB_0a in 'U_EGB_0A.PAS',
  13.   U_EGD_0a in 'U_EGD_0A.PAS',
  14.   SysUtils,WinCrt;
  15.  
  16. VAR
  17.   GenReader: tBufferedFileScanner;
  18.   StrReader: tBufTextStringFileReader;
  19.   pRec: pByteArray; LghRec: word; line: string;
  20.  
  21. {=====} BEGIN {========================================================}
  22.  
  23.   Writeln('Using tBufTextFileReader as a tBufferedFileReader');
  24. { Create an instance of the class which openes the file and allocates
  25.   a buffer.  Note that the "Reader" is of the abstract class.  }
  26.   GenReader:=tBufTextFileScanner.Create('TEST.DXF',128,98);
  27. { As long as LocNextVarLghRec function method can find a next record
  28.   keep doing the loop. }
  29.   With GenReader do while LocNextVarLghRec(pRec,LghRec) do begin
  30.   { Copy the line out of the buffer using the pointer, pRec. }
  31. (*  byte(line[0]):=LghRec; Move(pRec^,line[1],LghRec);
  32.   { Write the line out. }
  33.     WriteLn(' "',line,'"'); *)
  34.     end;
  35. { Return the buffer back to the system.}
  36.   Dispose(GenReader,Destroy);
  37.  
  38.   Writeln('Using tBufTextStringFileReader as itself');
  39. { Create an instance of the class which openes the file and allocates
  40.   a buffer.  Now the TextReader is of the actual object class.  }
  41.   StrReader:=tBufTextStringFileReader.Create('TEST.DXF',128);
  42. { As long as LocNextVarLghRec function method can find a next record
  43.   keep doing the loop. }
  44.   With StrReader do while GotLine(line) do begin
  45.   { Write the line out. (Or just selected lines.) }
  46.     If (line='EOF')
  47.       then WriteLn(LnNbr:5,' "',line,'"');
  48.     end;
  49. { Return the buffer back to the system and do any other cleanup.}
  50.   Dispose(StrReader,Destroy);
  51.   WriteLn('Finished');
  52.  
  53. {=====} END. {=========================================================}
  54.  
  55.